﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            DriveInfo driveInfo = new DriveInfo("D");
            Console.WriteLine("驱动器名称：{0}", driveInfo.Name);
            //驱动器类型中的 Fixed 值代表的本地磁盘
            Console.WriteLine("驱动器类型：{0}", driveInfo.DriveType);
            Console.WriteLine("驱动器的文件格式：{0}", driveInfo.DriveFormat);
            //本地磁盘、驱动器中可用空间的大小和总大小的单位是字节 (B)
            Console.WriteLine("驱动器中可用空间大小：{0}", driveInfo.TotalFreeSpace);
            Console.WriteLine("驱动器总大小：{0}", driveInfo.TotalSize);

            DriveInfo[] driveInfo1 = DriveInfo.GetDrives();
            foreach (DriveInfo d in driveInfo1)
            {
                /*IsReady	只读属性，获取一个指示驱动器是否已准备好的值
                ，True 为准备好了， False 为未准备好*/
                if (d.IsReady)
                {
                    Console.WriteLine("驱动器名称：" + d.Name);
                    Console.WriteLine("驱动器的文件格式:" + d.DriveFormat);
                }
            }


            
               //在D盘根目录下创建一个叫：mySolo的文件夹
               bool flag = Directory.Exists("D:\\mySolo");
               Console.WriteLine(flag);
               if (flag)
               {
                   Directory.Delete("D:\\mySolo", true);
               }
               else
               {
                   Directory.CreateDirectory("D:\\mySolo");
               }

            Directory.CreateDirectory("D:\\code");
            FileInfo fileInfo = new FileInfo("D:\\code\\test.txt");
            if (!fileInfo.Exists)
            {
                fileInfo.Create().Close();
            }
            fileInfo.Attributes = FileAttributes.Normal;
            Console.WriteLine("文件路径：" + fileInfo.Directory);
            Console.WriteLine("文件名称：" + fileInfo.Name);
            Console.WriteLine("文件是否只读：" + fileInfo.IsReadOnly);
            Console.WriteLine("文件大小：" + fileInfo.Length);

            string pash =@"D:\\code\\test.txt";
            StreamWriter streamWriter = new StreamWriter(pash);
            //写入信息
            streamWriter.WriteLine("胡歌");
            streamWriter.WriteLine("13063166466");
            streamWriter.Flush();
            streamWriter.Close();
        }
    }
}
